﻿@model sBlog.Net.Models.BlogPostPageViewModel
@{
    Layout = "~/Themes/Mlog/_Layout.cshtml";
    ViewBag.Title = string.Format("{0} {1} - {2}", "Nhật ký", Model.Category.CategoryName.ToLower(), Model.BlogName);
}
<script type="text/javascript">
    $(window).scroll(function () {
        if ($(this).scrollTop() > 100) {
            $('.scrollup').fadeIn();
        } else {
            $('.scrollup').fadeOut();
        }
    });

    $('.scrollup').click(function () {
        $("html, body").animate({ scrollTop: 0 }, 600);
        return false;
    });


    $(document).ready(function () {

        $(window).scroll(function () {
            if ($(this).scrollTop() > 100) {
                $('.scrollup').fadeIn();
            } else {
                $('.scrollup').fadeOut();
            }
        });

        $('.scrollup').click(function () {
            $("html, body").animate({ scrollTop: 0 }, 600);
            return false;
        });

    });
</script>
<script type="text/javascript">
    var intPage = 1;
    var cat = "@Model.Category.CategorySlug";
    var noCache = new Date().toString();
    $(window).scroll(function () {
        $('#container').masonry('reload');
        if ($(window).scrollTop() + $(window).height() > $(document).height() - 150) {
            intPage = intPage + 1;
            $.getJSON('/Home/LoadMoreDataCat?pageNumber=' + intPage + '&categoryName=' + cat, { noCache: noCache }, function (data) {
                $('#container').append(data);
                $('#container').masonry('reload');
            });
        }
    });

    $(function () {
        $('#container').masonry({
            columnWidth: 333,
            itemSelector: '.postHome'
        }).imagesLoaded(function () {
            $('#container').masonry('reload');
        });
    });
</script>
<div class="dvBlogListItem" id="container">
    @foreach (var post in Model.Posts)
    {   
        @Html.Partial("PostHome", post)
    }
</div>
<a href="#" class="scrollup"></a>